package com.tigercel.xiangchengyun.ui.activities

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.View
import com.tigercel.xiangchengyun.R
import com.tigercel.xiangchengyun.adapter.ImportantNewsAdapter
import com.tigercel.xiangchengyun.entity.ImportantNewsEntity

import kotlinx.android.synthetic.main.include_titlebar.*
import java.util.*

class ImportantNewsActivity : AppCompatActivity() {
    private var mRecyclerView: RecyclerView? = null
    private val mImportantNewsEntityList = ArrayList<ImportantNewsEntity>()
    private lateinit var mImportantNewsEntity: ImportantNewsEntity
    private var mImportantNewsAdapter: ImportantNewsAdapter? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_important_news)
        mRecyclerView = findViewById(R.id.recyclerView_news_important)
        mRecyclerView!!.layoutManager = LinearLayoutManager(this)
        for (i in 0..4) {
            mImportantNewsEntity = ImportantNewsEntity(i.toString(), "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1522765537318&di=d6ffbf06f8204eb28510cbc8784918c7&imgtype=0&src=http%3A%2F%2Fi1.hdslb.com%2Fbfs%2Farchive%2Ffbfc3e13a06f6581629970417c0d8ec5286ddfeb.jpg")
            mImportantNewsEntityList.add(mImportantNewsEntity)
        }
        mImportantNewsAdapter = ImportantNewsAdapter(this, mImportantNewsEntityList)
        mRecyclerView!!.adapter = mImportantNewsAdapter
        titlebar_tv.text = "要文推送"
        titlebar_iv_left.setImageDrawable(resources.getDrawable(R.drawable.btn_nav_back))
        titlebar_iv_left.visibility = View.VISIBLE
        titlebar_iv_left.setOnClickListener(View.OnClickListener { this.finish() })

    }
}
